package com.neudu.glsb.config;

import com.neudu.glsb.intercepter.UserIntercepter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
public class LoginConfig extends WebMvcConfigurationSupport {

    //拦截器注册成组件
    @Bean
    UserIntercepter userIntercepter(){
        return new UserIntercepter();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry){
        InterceptorRegistration interceptorRegistration = registry.addInterceptor(userIntercepter());
        interceptorRegistration.addPathPatterns("/**")
                .excludePathPatterns("/login", "login","/register","register","/captcha","captcha");
    }
}